#pragma once

#include <vector>
#include <math.h>

#include "algorithms/neuralnet.h"
#include "misc/utils.h"
#include "misc/vector2D.h"

#include "mine.h"

#include "zakengine/zak.h"

using namespace std;
using namespace zak;


class Minesweeper: public Sprite
{

private:

	Vector2D Pos;
	Vector2D LookAt;

	double Rotation;
	double Speed;

	double lTrack;
	double rTrack;

	double Fitness;

	int ClosestMine;

	NeuralNet* Brain;
  

public:


	Minesweeper();
	~Minesweeper();

	virtual bool			Initialize();
	
	//updates the ANN with information from the sweepers enviroment
	virtual void			Update(float dt, vector<Mine*> &mines);

	virtual void			Draw();

	void Move(double x, double y);

	//returns a vector to the closest mine
	Vector2D		GetClosestMine(vector<Mine*> &objects);

	//checks to see if the minesweeper has 'collected' a mine
	int				CheckForMine(vector<Vector2D> &mines, double size);

	void			Reset();
  

	//-------------------accessor functions
	Vector2D	Position()const{return Pos;}

	void		IncrementFitness(){++Fitness;}

	double		FitnessValue()const{return Fitness;}
  
	void		PutWeights(vector<double> &w){Brain->PutWeights(w);}

	int			GetNumberOfWeights()const{return Brain->GetNumberOfWeights();}
};

	
	